package com.haoshuang.zhouzhoubang.ui.page.order.take.record.fragment

import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemTakeOrderRecordBinding
import com.haoshuang.zhouzhoubang.model.bean.TakeOrderRecordBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.ktx.toDateString
import com.mufeng.libs.utils.view.imageResource
import com.mufeng.libs.utils.view.load
import com.mufeng.libs.utils.view.visibleOrGone


/**
 * 
 */
class TakeOrderRecordAdapter(data: MutableList<TakeOrderRecordBean>) : BaseBindingQuickAdapter<TakeOrderRecordBean, ItemTakeOrderRecordBinding>(data) {
    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: TakeOrderRecordBean?) {
        holder.getViewBinding<ItemTakeOrderRecordBinding>().apply {

            if (item == null) {
                return@apply
            }

            when (item.status) {
                0 -> {
                    tvStatus.text = "未支付"
                }
                1 -> {
                    tvStatus.text = "已支付"
                }
                2 -> {
                    tvStatus.text = "服务中"
                }
                3 -> {
                    tvStatus.text = "已完成"
                }
                4 -> {
                    tvStatus.text = "已取消"
                }
                5 -> {
                    tvStatus.text = "待接单"
                }
                6 -> {
                    tvStatus.text = "验收中"
                }
                else -> {
                    tvStatus.text = "组团中"
                }
            }

            tvCreateTime.text = "下单时间 ${((item.add_time?:0)*1000L).toDateString("yyyy-MM-dd HH:mm")}"
            rivImage.load(item.image)
            tvServiceName.text = item.store_name
            tvSuk.text = item.suk_unique
            ivOrderType.imageResource = when(item.show_status){
                1 -> R.mipmap.taoc
                2 -> R.mipmap.tddd09
                else -> R.mipmap.grdd09
            }
            tvPrice.text = item.pay_price
            tvServiceTime.text = item.service_time
            tvServiceAddress.text = item.user_address
            tvLook.visibleOrGone(item.status == 0)
        }
    }

}